package org.xue.snowmall.seckill.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.xue.snowmall.seckill.entity.SeckillRecordEntity;
import org.xue.snowmall.seckill.service.SeckillRecordService;
import org.xue.snowmall.common.utils.PageUtils;
import org.xue.snowmall.common.utils.R;
import org.xue.snowmall.seckill.vo.RelationVo;


/**
 * 
 *
 * @author zy
 * @email 2067065884@qq.com
 * @date 2021-09-28 21:27:12
 */
@RestController
@RequestMapping("seckill/seckillrecord")
public class SeckillRecordController {
    @Autowired
    private SeckillRecordService seckillRecordService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = seckillRecordService.queryPage(params);

        return R.ok().put("page", page);
    }

    @PostMapping("/saveSeckillRecord")
    public R saveSeckillRecord(@RequestBody List<RelationVo> formList) {
        return seckillRecordService.saveSeckillRecord(formList);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{gsmSeckillRecordId}")
    public R info(@PathVariable("gsmSeckillRecordId") Long gsmSeckillRecordId){
		SeckillRecordEntity seckillRecord = seckillRecordService.getById(gsmSeckillRecordId);

        return R.ok().put("seckillRecord", seckillRecord);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody SeckillRecordEntity seckillRecord){
		seckillRecordService.save(seckillRecord);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody SeckillRecordEntity seckillRecord){
		seckillRecordService.updateById(seckillRecord);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] gsmSeckillRecordIds){
		seckillRecordService.removeByIds(Arrays.asList(gsmSeckillRecordIds));

        return R.ok();
    }

}
